<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>友情链接恢复中心</title>
    <script src="__STATIC__admin/js/jquery-3.4.1.min.js"></script>
    <link rel="stylesheet" href="__STATIC__layui/css/layui.css">
    <script src="__STATIC__layui/layui.js"></script>
    <style>
        .current-color{
            background-color:#009688;
        }
        .divide-line {
            height: 45px;
            background-color: #EEF5F9;
            font-style: italic;
            font-weight: 600;
            line-height: 45px;
            font-size: 17px;
            color: #1E88E5;
        }

        .divide-line span {
            margin-left: 15px;
        }
        #layui-table-page1 {
            text-align: center;
        }

        .layui-table-cell {
            height: 55px;
            line-height: 55px;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo"><img src="static/admin/Font_Icon/沐歌logo2.png" width="70" height="70"
        >后台管理系统</div>
        <!-- 头部区域（可配合layui已有的水平导航） -->
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="{$Think.session.admin['adminPic']}" class="layui-nav-img" alt="{$Think.session.admin['adminName']}">
                    {$Think.session.admin['adminName']}
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="personaldata">基本资料</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item"><a href="#" onclick="loginOut()">注销</a></li>
            <script>
                function loginOut() {
                    layer.confirm('你确定要注销吗？', {
                        btn: ['确定', '算了'] //按钮
                    }, function () {
                        layer.msg('注销成功', {icon: 1});
                        setTimeout(function () {
                            location.href ="loginout";
                        },1000)
                    });
                }
            </script>
        </ul>
    </div>
    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">博客信息管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="{:url('admin/blog/blogList')}">博客列表</a></dd>
                        <dd><a href="{:url('admin/blog/blogAdd')}">添加博客</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">博客栏目管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="{:url('admin/category/categoryList')}">栏目列表</a></dd>
                        <dd><a href="{:url('admin/category/categoryAdd')}">添加栏目</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">用户管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="{:url('admin/user/userList')}">用户列表</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">留言管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="{:url('admin/Comment/commentList')}">评论列表</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">友情链接管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="{:url('admin/link/linkList')}">友情链接列表</a></dd>
                        <dd><a href="{:url('admin/link/linkAdd')}">添加友情链接</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">数据恢复中心</a>
                    <dl class="layui-nav-child">
                        <dd><a href="{:url('admin/DataRecoveryCenter/recoveryBlogList')}">博文回收站</a></dd>
                        <dd><a href="{:url('admin/DataRecoveryCenter/recoveryBlogTypeList')}">栏目回收站</a></dd>
                        <dd><a href="{:url('admin/DataRecoveryCenter/recoveryUserList')}">用户回收站</a></dd>
                        <dd class="current-color"><a href="{:url('admin/DataRecoveryCenter/recoveryLinkList')}">友情链接回收站</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item"><a href="">待定</a></li>
            </ul>
        </div>
    </div>
    <div class="layui-body">
        <!-- 内容主体区域 -->
        <!--        辅助线starting-->
        <div class="divide-line">
            <span>友情链接回收站</span>
        </div>
        <!--        辅助线ending-->
        <!--用户显示列表-->
        <!--        搜索栏starting-->
        <div class="demoTable">
            搜索域名：
            <div class="layui-inline">
                <input type="text" id="lname" name="lname" required lay-verify="required" placeholder="请输入..."
                       autocomplete="off" class="layui-input">
            </div>
            <button class="layui-btn layui-btn-normal" onclick="return false;" data-type="reload"
                    id="selectbyCondition">搜索
            </button>

        </div>
        <!--        搜索栏ending-->
        <div id="link"></div>
        <script type="text/html" id="operate">
            <button class="layui-btn layui-btn-xs" lay-event="edit" onclick="confirmRcovery('{{d.lid}}')">还原</button>
            <button class="layui-btn layui-btn-danger layui-btn-xs" onclick="confirmDel('{{d.lid}}')">删除</button>
        </script>
        <script>
            function confirmRcovery(lid) {
                layer.confirm('你确定要还原吗？', {
                    btn: ['还原', '算了'] //按钮
                }, function () {
                    $.ajax({
                        type: 'get',
                        url: "{:url('admin/DataRecoveryCenter/recoveryLink')}",
                        data: {lid},
                        dataType: 'json',
                        success: function (e) {
                            if (e.code == 1) {
                                layer.msg(e.msg, {icon: 1});
                                setTimeout(function () {
                                    location.reload();
                                }, 1000);
                            } else {
                                layer.msg(e.msg, function () {
//关闭后的操作
                                    setTimeout(function () {
                                        location.reload();
                                    }, 800)
                                });
                            }
                        }
                    });

                });
            }

            function confirmDel(lid) {
                layer.confirm('你确定要永久性删除吗？', {
                    btn: ['删除', '算了'] //按钮
                }, function () {
                    $.ajax({
                        type: 'get',
                        url: "{:url('admin/DataRecoveryCenter/recoveryDel')}",
                        data: {lid},
                        dataType: 'json',
                        success: function (e) {
                            if (e.code == 1) {
                                layer.msg(e.msg, {icon: 1});
                                setTimeout(function () {
                                    location.reload();
                                }, 1000);
                            } else {
                                layer.msg(e.msg, function () {
//关闭后的操作
                                    setTimeout(function () {
                                        location.reload();
                                    }, 800)
                                });
                            }
                        }
                    });
                });
            }
        </script>

        <script>
            layui.use('table', function () {
                var table = layui.table;
                table.render({
                    elem: '#link'
                    , url: "{:url('admin/DataRecoveryCenter/recoveryLinkQuery')}"
                    , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
                    , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                        layout: ['limit', 'count', 'prev', 'page', 'next', 'first', 'skip'] //自定义分页布局
                        //,curr: 5 //设定初始在第 5 页
                        , limit: 5 //一页显示多少条
                        , limits: [5, 10, 15]//每页条数的选择项
                        , groups: 5 //只显示 2 个连续页码
                        , first: "首页" //不显示首页
                        , last: "尾页" //不显示尾页
                    }
                    , cols: [[
                        {field: 'lid', width: 300, title: 'ID', sort: true}
                        , {field: 'lname', width: 450, title: '友情链接'}
                        , {field: 'url', width: 900, title: 'URL'}
                        , {fixed: 'right', title: '操作', toolbar: '#operate', width: 180}
                    ]],
                    id: 'linkTableReload',
                    done: function (res) {
                        console.log(res.data)
                        $(function () {
                            $('#sum').text(res.count);
                        })
                    }
                });
                //表格的重载starting
                //根据条件查询表格数据重新加载
                var $ = layui.$, active = {
                    reload: function () {
                        //获取用户名
                        var demoReload = $('#lname');
                        //执行重载
                        table.reload('linkTableReload', {
                            where: {
                                lname: demoReload.val()
                            }
                        });
                    }
                };
                //点击搜索按钮根据用户名称查询
                $('#selectbyCondition').on('click',
                    function () {
                        if ($('#lname').val().trim()==''){
                            layer.msg('输入内容不能为空！！！', function(){
//关闭后的操作
                            });
                            return false
                        }
                        var type = $(this).data('type');
                        active[type] ? active[type].call(this) : '';
                    }
                );
                //    表格的重载ending
            });

        </script>

        <!--        图片显示的一对标签-->
        <script type="text/html" id="pic">
            <!--            <img src="/static/admin/user/2.jpg" alt="/static/admin/user/2.jpg" width="95" height="55">-->
            <img src="{{d.pic}}" alt="{{d.uname}}" width="95" height="55">
        </script>
        <!--        事件处理-->
        <!--  主体 ending     -->
    </div>
    <div class="layui-footer">
        <!-- 底部固定区域 -->
        © 沐丶歌丨
    </div>
</div>
<script>
    //JavaScript代码区域
    layui.use('element', function () {
        var element = layui.element;
    });

</script>
</body>
</html>
